import { createBrowserRouter, Navigate } from "react-router-dom";


import Login from "../pages/login";
import NotFound from '../pages/notFound'
import Layout  from "@/pages/layout";
import Register from "../pages/register";
import Main from "../pages/main";
import Home from "../pages/home"
import Profile from "../pages/profile";
import TorrentList from "../pages/torrentList";
import UserDetailPage from "../pages/UserDetailPage";
import AdminLayout from "../pages/admin/AdminLayout";
import AdminDashboard from "../pages/admin/Dashboard";
import AdminPromotionRules from "../pages/admin/PromotionRules";
import AdminUserManagement from "../pages/admin/UserManagement";
import AdminTorrentList from "../pages/admin/AdminTorrentList";


const router = createBrowserRouter([
     {
    path: '/',
    element: <Navigate to="/login" replace />, // 根路径重定向
  },
    {
        path: '/login',
        element: <Login/>
    },
    {
        path: '/register',
        element: <Register/>
    },
    {
        path: '/profile',
        element: <Profile/>
    },
    {
        path:'/torrentList',
        element:<TorrentList/>
    },
    {
        path: '/user/:userId',  // 使用动态路由参数
    element: <UserDetailPage />
    },
    {
        path: "/ptuser",
        Component: Main,
        children: [
            {
                path: "home",
                Component: Home
            }
        ]
    },
    {
        path: '/admin',
        element: <AdminLayout />,
        children: [
            {
                path: '',
                element: <Navigate to="promotion-rules" replace />
            },
           
            {
                path: 'promotion-rules',
                element: <AdminPromotionRules />
            },
            {
                path: 'user-management',
                element: <AdminUserManagement />
            },
            {
                path: 'torrent-management',
                element: <AdminTorrentList />
            }
        ]
    },
    {
        path:'*',
        element:<NotFound/>
    }
])

export default router